package com.ruoyi.common.utils;

/**
 * @description: 扩展hutool正则表达式
 * @author: duanyashu
 * @time: 2021-07-16 14:37
 */
public class ReUtil extends cn.hutool.core.util.ReUtil {

    //只能输入整数或者小数
    public static final String DECIMAL = "^[0-9]+\\.{0,1}[0-9]{0,2}$";
    public static final String DECIMAL_MSG = "只能输入整数或者小数";

    //数字和字母
    public static final String NUMBER_LETTER = "^[a-z0-9A-Z]+$";
    public static final String NUMBER_LETTER_MSG = "只能输入数字和字母";

    //密码 6-12位数字和字母
    public static final String PASSWORD="^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$";
    public static final String PASSWORD_MSG="密码需要6-12位数字和字母";

    //数字
    public static final String NUMBER = "^[0-9]*$";
    public static final String NUMBER_MSG = "只能输入数字";

    //性别
    public static final String SEX ="^[男女]$";
    public static final String SEX_MSG="性别只能为【男女】";

    //手机号
    public static final String PHONE="^[1][3,4,5,6,7,8,9][0-9]{9}$";
    public static final String PHONE_MSG="手机号不正确";

    //身份证
    public static final String IDENTITY="^[1-9][0-9]{5}(19[0-9]{2}|200[0-9]|2010)(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01])[0-9]{3}[0-9xX]$";
    public static final String IDENTITY_MSG="身份证格式不正确";

    public static final String TEXT="^[\\u4e00-\\u9fa5]{0,}$";
    public static final String TEXT_MSG="只能是中文";

    public static final String E_MAIL="^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
    public static final String E_MAIL_MSG="邮箱格式不正确";

    public static final String DATE="^((\\d{2}(([02468][048])|([13579][26]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][1235679])|([13579][01345789]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\\s(((0?[0-9])|([1][0-9])|([2][0-4]))\\:([0-5]?[0-9])((\\s)|(\\:([0-5]?[0-9])))))?$";
    public static final String DATE_MSG="日期格式不正确";
    /**
     * 手机号匹配
     * @param phone
     * @return
     */
   public static boolean isMatchPhone(String phone){
        return isMatch(PHONE,phone);
   }
    /**
     * 身份证格式匹配
     * @param phone
     * @return
     */
   public static boolean isMatchIdentity(String phone){
        return isMatch(IDENTITY,phone);
   }


    /**
     * 邮箱格式校验
     * @param email
     * @return
     */
   public static boolean isMatchEmail(String email){
        return isMatch(E_MAIL,email);
   }



}
